package model;

import javafx.beans.property.SimpleStringProperty;

public class Book extends Item
{
    public enum Fiction
    {
        SCIENCE,
        MAGAZINE,
        CHILDREN,
        POEMS,
        COOKING,
        UNKNOWN
    }

    private final SimpleStringProperty bookTitle;
    private final SimpleStringProperty author;
    private Publisher publisher;
    private final SimpleStringProperty ISBN10;
    private final SimpleStringProperty ISBN13;
    private Fiction fiction;
 

    public Book()
    {
        super();

        bookTitle = new SimpleStringProperty("N/A");
        author = new SimpleStringProperty("N/A");
        publisher = new Publisher();
        ISBN10 = new SimpleStringProperty("N/A");
        ISBN13 = new SimpleStringProperty("N/A");
        fiction = Fiction.UNKNOWN;
        
    }

    public Book(String itemCode, int quantityInHand, double costPrice, double sellingPrice, Status status, int discount,
                String title, String auth, Publisher publisher, String IN10, String IN13, Fiction fiction)
    {
        super(itemCode, quantityInHand, costPrice, sellingPrice, status, discount);

        this.bookTitle = new SimpleStringProperty(title);
        this.author = new SimpleStringProperty(auth);
        this.publisher = publisher;
        this.ISBN10 = new SimpleStringProperty(IN10);
        this.ISBN13 = new SimpleStringProperty(IN13);
        this.fiction = fiction;
        
    }

    public Book(Book book)
    {
        super(book);

        this.bookTitle = book.bookTitle;
        this.author = book.author;
        this.publisher = new Publisher(book.publisher);
        this.ISBN10 = book.ISBN10;
        this.ISBN13 = book.ISBN13;
        this.fiction = book.fiction;
    }

    public String getBookTitle()
    {
        return bookTitle.get();
    }

    public void setBookTitle(String title)
    {
        bookTitle.set(title);
    }
    
    public String getAuthor()
    {
        return author.get();
    }

    public void setAuthor(String auth)
    {
        author.set(auth);
    }

    public Publisher getPublisher()
    {
        return publisher;
    }

    public void setPublisher(Publisher publisher)
    {
        this.publisher = publisher;
    }

    public String getISBN10()
    {
        return ISBN10.get();
    }

    public void setISBN10(String IN10)
    {
        ISBN10.set(IN10);
    }

    public String getISBN13()
    {
        return ISBN13.get();
    }

    public void setISBN13(String IN13)
    {
        ISBN13.set(IN13);
    }

    public Fiction getFiction()
    {
        return fiction;
    }

    public void setFiction(Fiction fiction)
    {
        this.fiction = fiction;
    }

    @Override
    public boolean equals(Object o)
    {
        if(!(o instanceof Book))
            return false;

        Book book = (Book)o;

        if(!book.getItemCode().equals(getItemCode()))
            return false;
        if(book.getQuantityInHand() != getQuantityInHand())
            return false;
        if(book.getCostPrice() != getCostPrice())
            return false;
        if(book.getSellingPrice() != getSellingPrice())
            return false;
        if(book.getStatus() != getStatus())
            return false;
        if(book.getDiscount() != getDiscount())
            return false;

        if(!book.getBookTitle().equals(getBookTitle()))
            return false;
        if(!book.getAuthor().equals(getAuthor()))
            return false;
        if(!book.getPublisher().equals(getPublisher()))
            return false;
        if(!book.getISBN10().equals(getISBN10()))
            return false;
        if(!book.getISBN13().equals(getISBN13()))
            return false;
        if(!book.getFiction().equals(getFiction()))
            return false;

        return true;
    }
}